package com.kang.scheduling;

import com.kang.service.RedisToMySqlService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
@EnableScheduling
@Slf4j
public class RedisToMySql {

    @Autowired
    private RedisToMySqlService redisToMySqlService;


    @Scheduled(fixedRate = 1000 * 60 * 60* 24)
    @Async
    public void redisToMySql() {
        try {
            redisToMySqlService.redisToMySql();
        } catch (Exception ex) {
            log.error("redis数据同步到mysql失败");
        }
    }

}
